package com.example.travelcomponentdemo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.example.component.HorizontalPagerWithPageControl;

public class HorizontalPagerWithPageControlActivity extends Activity {
	private HorizontalPagerWithPageControl m_pager;
	// The data to show
	List<Map<String, String>> planetsList = new ArrayList<Map<String, String>>();
	@Override
	public void onCreate(final Bundle p_savedInstanceState) {
	    super.onCreate(p_savedInstanceState);
	    setContentView(R.layout.horizontal_pager_with_page_control);
	    m_pager = (HorizontalPagerWithPageControl) findViewById(R.id.hphorizontal_pager);
	    /*
	     * You can add more views to the horizontal pager here with
	     * mPager.addChild() or in xml. When every view is in the horizontal
	     * pager just call addPagerControl() on the horzizontal pager.
	     */
//	    initList();
	    // We get the ListView component from the layout
//	    ListView lv = (ListView) findViewById(R.id.listView);
	    // This is a simple adapter that accepts as parameter
	    // Context
	    // Data list
	    // The row layout that is used during the row creation
	    // The keys used to retrieve the data
	    // The View id used to show the data. The key number and the view id
	    // must match
//	    SimpleAdapter simpleAdpt = new SimpleAdapter(this, planetsList,
//	            android.R.layout.simple_list_item_1, new String[] { "planet" },
//	            new int[] { android.R.id.text1 });
//	    lv.setAdapter(simpleAdpt);
	    m_pager.addPagerControl();
	}
	private void initList() {
	    // We populate the planets
	    planetsList.add(createPlanet("planet", "Mercury"));
	    planetsList.add(createPlanet("planet", "Venus"));
	    planetsList.add(createPlanet("planet", "Mars"));
	    planetsList.add(createPlanet("planet", "Jupiter"));
	    planetsList.add(createPlanet("planet", "Saturn"));
	    planetsList.add(createPlanet("planet", "Uranus"));
	    planetsList.add(createPlanet("planet", "Neptune"));
	}
	private HashMap<String, String> createPlanet(String key, String name) {
	    HashMap<String, String> planet = new HashMap<String, String>();
	    planet.put(key, name);
	    return planet;
	}
}
